package io.mya.modules.sys.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * 糖果主要Controller 例如跳转等
 */
@Controller
@RequestMapping("/candyboxbis")
public class CandyBusinessController {
    /**
     * 跳转index.html页面
     * @return
     */
    @RequestMapping("/candyboxPage")
    public String indexHtml(HttpServletRequest request, HttpServletResponse response) {
//	  return "CandyLogin";
//        return "CandyLogin";
//		return "modules/candy/invitefriends";

        request.setAttribute("registerMail",request.getParameter("registerMail"));
        request.setAttribute("invitecode",request.getParameter("invitecode"));
		return "modules/candy/candybox";
//				return "modules/candy/about";
    }

    /**
     * 跳转index.html页面
     * @return
     */
    @RequestMapping("/invitefriendsPage")
    public String invitefriendsPage(HttpServletRequest request, HttpServletResponse response) {
//	  return "CandyLogin";
//        return "CandyLogin";
//		return "modules/candy/invitefriends";

        String registerMail = request.getParameter("registerMail");
        request.setAttribute("registerMail",registerMail);
        return "modules/candy/invitefriends";
//				return "modules/candy/about";
    }

    /**
     * 邀请码--》跳转到登录页面并吧邀请码带过去
     * @return
     */
    @RequestMapping(value = "/invcode/{code}", method = RequestMethod.GET)
    public Object inviteCode(@PathVariable("code") String code,HttpServletRequest request, HttpServletResponse response) {

        Map<String, String> objMap = new HashMap<>();

        request.setAttribute("code",code);

        return "CandyLogin";

    }
}
